﻿using System.Data;
using System.Linq;
using System.Web.Mvc;
using SmesharikiMVC.Models.VideoCollection;

namespace SmesharikiMVC.Areas.Admin.Controllers
{
    public class VideoController : Controller
    {
        private VideoCollectionContext db = new VideoCollectionContext();

        //
        // GET: /Admin/YoutubeVideo/
        [Authorize]
        public ViewResult Index()
        {
            return View(db.Videos.ToList());
        }

        //
        // GET: /Admin/Video/Delete/5
        [Authorize]
        public ActionResult Delete(int id)
        {
            YoutubeVideo video = db.Videos.Find(id);
            db.Videos.Remove(video);
            var deleted = db.SaveChanges() > 0;

            return Json(deleted, JsonRequestBehavior.AllowGet);
        }

    }
}
